<?php
/**
 * @description : generate the consumer & secret key.
 * @author : stephen.mo
 * @date : 2010/08/04
 */

class OAuthGenerateSecretKey {/*{{{*/

    static public function generateKey($consumer_name,$consumer_flag) {/*{{{*/
        $consumer_key = sha1($consumer_name.self::getRandom().$consumer_flag);
        $secret_key = strtoupper(sha1($consumer_key.self::getRandom()));
        $obj = new stdclass();
        $obj->name = $consumer_name;
        $obj->key = $consumer_key;
        $obj->secret = $secret_key;
        $obj->flag = $consumer_flag;
        return $obj;
    }/*}}}*/

    static public function getRandom() {/*{{{*/
        $mt = microtime();
        $rand = mt_rand();
        return md5($mt . $rand);
    }/*}}}*/

}/*}}}*/

//OGS-short class name.
final class OGS extends OAuthGenerateSecretKey{}

?>
